package com.life.wd.controller;

import com.life.wd.dto.VideoDTO;
import com.life.wd.dto.VideoSearchDTO;
import com.life.wd.result.PageResult;
import com.life.wd.result.Result;
import com.life.wd.service.VideoService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/video")
@Slf4j
@Api(tags = "视频管理")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @PostMapping
    public Result<PageResult> select(@RequestBody VideoSearchDTO videoSearchDTO) {
        log.info("查询视频：{}", videoSearchDTO);
        PageResult videoList = videoService.pageQuery(videoSearchDTO);
        return Result.success(videoList);
    }

    @PutMapping
    public Result update(@RequestBody List<VideoDTO> videoDTOList) {
        log.info("审核视频：{}", videoDTOList);
        videoService.checkVideoService(videoDTOList);
        return Result.success(videoDTOList.get(0).getStatus() == 1 ? "视频已通过审核" : "视频未通过审核");
    }
}
